package com.oop;

public class Animal {

     String name = "animal";

    public void  eat(){
        System.out.println("animal is eatting !!!");
    }
}

class Pig extends Animal{
     String name = "pig";
    public void  eat(){
        System.out.println("pig is eatting !!!");
    }

}


class test02{

    public static void main(String[] args) {

        //多态
        //父类引用 指向 子类对象
        //重写 @Override   执行方法 父类必须有 没有就报错

        //方法看右边
        //变量看左面

        Animal sb = new Pig();
        sb.eat();
        System.out.println(sb.name);
    }
}